package com.kdgc.power.aspect;

import com.kdgc.power.common.util.StringUtil;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

@Component
@Aspect
public class AspectService {
//    @Before(value = "@annotation(LogAnnotation)")
//    public void before(JoinPoint point) {
//        System.out.println("方法执行之前");
//        Object[] args = point.getArgs();
//        StringUtil.print(args);
//    }
//
//    @After(value = "@annotation(LogAnnotation)")
//    public void after(JoinPoint point) {
//        System.out.println("方法执行之后");
//
//    }
//
//    @AfterReturning(value = "@annotation(LogAnnotation)", returning = "result")
//    public void afterReturn(JoinPoint point, String result) {
//        System.out.println("返回结果:" + result);
//
//    }
//
//    @AfterThrowing(value = "@annotation(LogAnnotation)", throwing = "exception")
//    public void afterReturn(JoinPoint point, Throwable exception) {
//        System.out.println("异常切面逻辑");
//        System.out.println(exception.getMessage());
//
//    }

//    @Around(value = "@annotation(LogAnnotation)")
//    public void around(ProceedingJoinPoint point) {
//        try {
//            System.out.println("方法执行之前");
//            point.proceed();
//
//        } catch (Throwable e) {
//            System.out.println("异常切面");
//            throw new RuntimeException(e);
//        } finally {
//            System.out.println("方法执行之后");
//        }
//
//    }
}
